
const app = getApp()
const ipconfig = app.globalData.ipconfig;
const get =(path,data,callback)=>{
    wx.request({
        url: 'http://' + ipconfig + ':8080'+path,
        method: 'GET',
        data: data,
        header: {
            'Authorization': wx.getStorageSync('token')
        },
        success: function (res) {
            callback(res)
        },
        fail: function (err) {
            console.log("请求失败",err);
        }
    })
}

const getNoHeader =(path,data,callback)=>{
    wx.request({
        url: 'http://' + ipconfig + ':8080'+path,
        method: 'GET',
        data: data,
        success: function (res) {
            callback(res)
        },
        fail: function (err) {
            console.log("请求失败",err);
        }
    })
}

const post =(path,data,callback)=>{
    wx.request({
        url: 'http://' + ipconfig + ':8080' + path,
        method: 'POST',
        data: data,
        header: {
            'Authorization': wx.getStorageSync('token')
        },
        success: function (res) {
            callback(res)
        },
        fail: function (err) {
            
            console.log("请求失败",err);
        }
    })
}

const postNoHeader =(path,data,callback)=>{
    wx.request({
        url: 'http://' + ipconfig + ':8080' + path,
        method: 'POST',
        data: data,
        success: function (res) {
            callback(res)
        },
        fail: function (err) {
            
            console.log("请求失败",err);
        }
    })
}
module.exports = {
    get,
    post,
    postNoHeader,
    getNoHeader
  }